import { AxiosPromise } from "axios";
import request from "@/utils/request";
import { UserPageVO, UserForm, TeacherQuery, StudentQuery } from "./types";

/**
 * 获取导师分页列表
 *
 * @param queryParams
 */
export function getTeacherPage(
  queryParams?: TeacherQuery
): AxiosPromise<PageResult<UserPageVO[]>> {
  return request({
    url: "/api/user/page/teacher",
    method: "get",
    params: queryParams,
  });
}
/**
 * 获取学生分页列表
 *
 * @param queryParams
 */
export function getStudentPage(
  queryParams?: StudentQuery
): AxiosPromise<PageResult<UserPageVO[]>> {
  return request({
    url: "/api/user/page/student",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取用户表单详情
 *
 * @param userId
 */
//用户信息
export function getUserForm(userId: string): AxiosPromise<UserForm> {
  return request({
    url: "/api/user/" + userId,
    method: "get",
  });
}
// //项目信息
// export function getProjectForm(userId: string): AxiosPromise<UserForm> {
//   return request({
//     url: "/api/project/0",
//     method: "get",
//   });
// }

// /**
//  * 添加用户
//  *
//  * @param data
//  */
// //添加导师信息
// export function addTeacher(data: UserForm, type: number) {
//   return request({
//     url: "/api/user/add",
//     method: "post",
//     data: {
//       college: data.college,
//       email: data.email,
//       enrollmentYear: data.enrollmentYear,
//       excelField: data.excelField,
//       hobby: data.hobby,
//       honor: data.honor,
//       image: data.image,
//       innovationExp: data.innovationExp,
//       job: data.job,
//       major: data.major,
//       name: data.name,
//       phone: data.phone,
//       post: data.post,
//       skills: data.skills,
//       projectList: data.projectList,
//       type: type,
//       userName: data.userName,
//       workExp: data.workExp,
//     },
//   });
// }
// //添加学生信息
// export function addStudent(data: UserForm, type: number) {
//   return request({
//     url: "/api/user/add",
//     method: "post",
//     data: {
//       email: data.email,
//       enrollmentYear: data.enrollmentYear,
//       excelField: data.excelField,
//       hobby: data.hobby,
//       honor: data.honor,
//       image: data.image,
//       innovationExp: data.innovationExp,
//       job: data.job,
//       major: data.major,
//       name: data.name,
//       officeId: data.officeId,
//       phone: data.phone,
//       post: data.post,
//       skills: data.skills,
//       projectList: data.projectList,
//       type: type,
//       userName: data.userName,
//       workExp: data.workExp,
//     },
//   });
// }
// //添加项目
// export function addProject(data: any) {
//   return request({
//     url: "/api/project/add",
//     method: "post",
//     data: {
//       data,
//     },
//   });
// }

/**
 * 修改用户
 *
 * @param id
 * @param data
 */
//修改项目
// export function updateProject(data: UserForm) {
//   return request({
//     url: "/api/user/update",
//     method: "put",
//     data: {
//       data,
//     },
//   });
// }
//修改用户信息
export function updateUser(data: UserForm) {
  data.id = data.userId;
  return request({
    url: "/api/user/pc/update",
    method: "put",
    data: {
      id: data.id,
      college: data.college,
      email: data.email,
      enrollmentYear: data.enrollmentYear,
      excelField: data.excelField,
      hobby: data.hobby,
      honor: data.honor,
      image: data.image,
      innovationExp: data.innovationExp,
      job: data.job,
      major: data.major,
      name: data.name,
      officeId: data.officeId,
      phone: data.phone,
      post: data.post,
      skills: data.skills,
      projectList: data.projectList,
      workExp: data.workExp,
    },
  });
}

/**
 * 删除用户
 *
 * @param id
 */
//删除用户信息
export function deleteUsers(id: string) {
  return request({
    url: "/api/user/delete",
    method: "delete",
    data: {
      id,
    },
  });
}
//删除项目
export function deleteProjects(id: string) {
  return request({
    url: "/api/project/delete",
    method: "delete",
    data: {
      id,
    },
  });
}

// 上传图片
export function uploadImage(img: any) {
  const formData = new FormData();
  formData.append("img", img);
  return request({
    url: "/api/common/upload/img",
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}
